#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: v1api03_metadata.py 
@version:
@time: 2022/05/10 
"""
import json

from TapClientCore.T02_tm_api.v1_api.v1_api_base import *


class V1MetaData(V1ApiBase, ):

    def __init__(self, change=''):
        super(V1MetaData, self).__init__(change)
        self.url_metadata = api_joint(self.server, 'MetadataInstances')
        self.url_metadata_schema = api_joint(self.url_metadata, 'schema')
        self.url_metadata_originalData = api_joint(self.url_metadata, 'originalData')
        self.url_metadata_update = api_joint(self.url_metadata, 'update')

    # 查询
    def get_metadata(self):
        response = self.tapclient(
            self.get,
            self.url_metadata
        )
        return response

    # 查询 by filter
    def get_metadata_by_filter(self, _filter):
        f = json.dumps(_filter)
        response = self.tapclient(
            self.get,
            self.url_metadata
            + self.filter(f)
        )
        return response

    # 查询 schema by filter
    def get_metadata_by_model_name(self, _filter):
        f = json.dumps(_filter)
        response = self.tapclient(
            self.get,
            self.url_metadata_schema
            + self.filter(f)
        )
        return response

    # 删除 metadata
    def delete_metadata_by_id(self, meta_id):
        response = self.tapclient(
            self.delete,
            api_joint(
                self.url_metadata,
                meta_id
            )
        )
        return response

    # 更新
